function fn() {
  return new Promise(function (resolve, reject) {
    setTimeout(function () {
      resolve(1);
    }, 1000);
  });
  function foo() {
    var a = 1;
    function bar() {
      console.log(a);
    }

    return bar;
  }
}

var baz = foo();
baz();
fn().then(function (data) {
  console.log(data);
});
